﻿<div class="row-fluid page-content">
    <div id="page-inner">
        <div class="row">
            <div class="col-md-12">
                <div class="page-head-line location">
                    <span>位置：</span>
                    <ul>
                        <li><a href="/">首页</a></li>
                        <li>信息维护</li>
                        <li>人员档案</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row cls-list">
            <div class="col-md-12">
                <div id="toolbar">
                    <div>
                        <div class="form-inline" role="form">
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">姓名: </span>
                                    <input name="Name" type="text" class="form-control query-Name" />
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">身份证: </span>
                                    <input name="IdNo" type="text" class="form-control query-IdNo" />
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">出生日期: </span>
                                    <input name="Birthday" type="text" class="form-control date query-Birthday" />
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">上岗日期: </span>
                                    <input name="WorkStart" type="text" class="form-control date query-WorkStart" />
                                </div>
                            </div>
                            <div class="form-group col-md-4">
                                <div class="input-group">
                                    &nbsp;
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="form-inline" role="form">
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">性别: </span>
                                    <select name="Gender" class="form-control query-Gender">
                                        <option>女</option>
                                        <option>男</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">性质: </span>
                                    <select name="Type" class="form-control query-Type"></select>
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">状态: </span>
                                    <select name="Status" class="form-control query-Status">
                                        <option value="" selected="selected">所有</option>
                                        <option value="在职">在职</option>
                                        <option value="离职">离职</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group col-md-2">
                                <div class="input-group">
                                    <span class="input-group-addon">技能: </span>
                                    <select name="Skill" class="form-control query-Skill"></select>
                                </div>
                            </div>
                            <div class="form-group col-md-4">
                                <div class="input-group">
                                    <button class="query btn btn-primary"><i class="fa fa-search fa-lg"></i>查 询</button>
                                    <button class="add btn btn-default"><span class="add"></span>增 加</button>
                                    <button class="delete btn btn-default"><span class="delete"></span>删 除</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <table id="crewViewTable" class="myTable"></table>
            </div>
        </div>
        <div class="row cls-edit" style="display:none;">
            <div class="col-md-12">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">人员信息</h3>
                    </div>
                    <div class="panel-body">
                        <form id="editForm" action="EditCrew" method="post" enctype="multipart/form-data">
                            <input class="Id" name="Id" type="hidden" />
                            <input class="cls-form-reset" type="reset" style="display:none;" />
                            <table>
                                <tr>
                                    <td class="title"><font color="red">*</font> 姓 名：</td>
                                    <td class="content"><input type="text" name="Name" class="Name form-control" /></td>
                                    <td class="title"><font color="red">*</font> 身份证号：</td>
                                    <td class="content"><input name="IdNo" type="text" class="IdNo form-control" /></td>
                                    <td class="preview" colspan="2" rowspan="10">
                                        <div>
                                            <img alt="" src="" />
                                        </div>
                                    </td>
                                </tr>
                                <tr>

                                    <td class="title"><font color="red">*</font> 性 别：</td>
                                    <td class="content">
                                        <select name="Gender" class="Gender form-control">
                                            <option>女</option>
                                            <option>男</option>
                                        </select>
                                    </td>
                                    <td class="title">签发机关：</td>
                                    <td class="content"><input name="IdIssuer" type="text" class="IdIssuer form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title"><font color="red">*</font> 性 质：</td>
                                    <td class="content">
                                        <select name="Type" class="Type form-control"></select>
                                    </td>
                                    <td class="title">暂住证号：</td>
                                    <td class="content"><input name="TrcNo" type="text" class="TrcNo form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title"><font color="red">*</font> 状 态：</td>
                                    <td class="content">
                                        <select name="Status" class="Status form-control">
                                            <option>在职</option>
                                            <option>离职</option>
                                        </select>
                                    </td>
                                    <td class="title">签发机关：</td>
                                    <td class="content"><input name="TrcIssuer" type="text" class="TrcIssuer form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title"><font color="red">*</font> 技 能：</td>
                                    <td class="content">
                                        <select name="Skill" class="Skill form-control"></select>
                                    </td>

                                    <td class="title">签发日期：</td>
                                    <td class="content"><input name="TrcStart" type="text" class="TrcStart date form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title"><font color="red">*</font> 等 级：</td>
                                    <td class="content">
                                        <select name="Level" class="form-control">
                                            <option>一级</option>
                                            <option>二级</option>
                                            <option>三级</option>
                                        </select>
                                    </td>

                                    <td class="title">健康证号：</td>
                                    <td class="content"><input name="HealthNo" type="text" class="HealthNo form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">所属单位：</td>
                                    <td class="content">
                                        <select name="OwnerUnitId" class="OwnerUnitId form-control"></select>
                                    </td>
                                    <td class="title">签发机关：</td>
                                    <td class="content"><input name="HealthIssuer" type="text" class="HealthIssuer form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">服务单位：</td>
                                    <td class="content">
                                        <select name="ServiceUnitId" class="ServiceUnitId form-control"></select>
                                    </td>

                                    <td class="title">发证日期：</td>
                                    <td class="content"><input name="HealthStart" type="text" class="HealthStart date form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">出生日期：</td>
                                    <td class="content"><input name="Birthday" type="text" class="Birthday date form-control" /></td>

                                    <td class="title">上岗证号：</td>
                                    <td class="content"><input name="LicenseNo" type="text" class="LicenseNo form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">籍 贯：</td>
                                    <td class="content"><input name="Native" type="text" class="Native form-control" /></td>
                                    <td class="title">上岗类别：</td>
                                    <td class="content">
                                        <select name="LicenseType" class="LicenseType form-control">
                                            <option>护工上岗证</option>
                                            <option>母婴护理证</option>
                                            <option>养老护理证</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="title">联系电话：</td>
                                    <td class="content"><input name="Tel" type="text" class="Tel form-control" /></td>
                                    <td class="title">签发机关：</td>
                                    <td class="content"><input name="LicenseIssuer" type="text" class="LicenseIssuer form-control" /></td>
                                    <td class="title">照 片：</td>
                                    <td class="content"><input name="file" type="file" class="file form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">上岗日期：</td>
                                    <td class="content"><input name="WorkStart" type="text" class="WorkStart date form-control" /></td>
                                    <td class="title">发证日期：</td>
                                    <td class="content"><input name="LicenseStart" type="text" class="LicenseStart date form-control" /></td>
                                    <td class="title">培 训：</td>
                                    <td class="content"><input name="Training" type="text" class="Training form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title">离岗日期：</td>
                                    <td class="content"><input name="WorkEnd" type="text" class="WorkEnd date form-control" /></td>
                                    <td class="title">家庭住址：</td>
                                    <td class="content"><input name="Addr" type="text" class="Addr form-control" /></td>
                                    <td class="title">备 注：</td>
                                    <td class="content"><input name="Note" type="text" class="Note form-control" /></td>
                                </tr>
                                <tr>
                                    <td class="title"><font color="red">*</font> 结算标准：</td>
                                    <td class="content">
                                        <select name="PaymentId" class="PaymentId form-control"></select>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="panel-footer">
                        <button class="save btn btn-success"><i class="fa fa-save fa-lg"></i> 保 存</button>
                        <button class="cancel btn btn-danger"><i class="fa fa-close fa-lg"></i> 取 消</button>
                    </div>
                </div>
            </div>
        </div>

        <!--排程数据-->
        <div class="row cls-list-schedule" style="display:none">
            <div class="col-md-12">
                <div id="toolbar-schedule">
                    <div class="form-inline" role="form">
                        <div class="form-group col-md-2">
                            <div class="input-group">
                                <span class="input-group-addon">客户姓名: </span>
                                <input name="CustomerName" type="text" class="form-control query-CustomerName" />
                            </div>
                        </div>
                        <div class="form-group col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon">开始: </span>
                                <input name="Start" type="date" class="form-control query-Start" />
                            </div>
                        </div>
                        <div class="form-group col-md-3">
                            <div class="input-group">
                                <span class="input-group-addon">结束: </span>
                                <input name="End" type="date" class="form-control query-End" />
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                            <div class="input-group">
                                <button class="query btn btn-primary"><i class="fa fa-search fa-lg"></i>查 询</button>
                                <button class="delete btn btn-default"><span class="delete"></span>删 除</button>
                                <button class="cancel btn btn-default"><span class="cancel"></span>返 回</button>
                            </div>
                        </div>
                    </div>
                </div>
                <table id="scheduleTable" class="myTable"></table>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid page-content">
    <div id="page-inner-schedule" style="display:none">
        <div class="row">
            <div class="col-md-12">
                <div class="page-head-line location">
                    <span>位置：</span>
                    <ul>
                        <li><a href="/">首页</a></li>
                        <li>信息维护</li>
                        <li>人员档案</li>
                    </ul>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("input.date").datepicker({
            changeYear: true,
            showButtonPanel: true
        });
        $("input.datetime").datetimepicker({
            changeYear: true,
            showButtonPanel: true,
            hour: 8
        });

        $("#editForm").attr("action", window._util.BASE_URL + "/Business/EditCrew");
        initTable();

        function initSelect() {
            //人员性质
            if (window._util.ItemCode.CrewType != null) {
                var htmlStr = "";
                $.each(window._util.ItemCode.CrewType, function (ix, item) {
                    htmlStr += '<option value="' + item.Value + '">' + item.Text + '</option>';
                });

                $("#editForm .Type").html(htmlStr);
                htmlStr = '<option value="" selected="selected">所有</option>' + htmlStr;
                $("#toolbar .query-Type").html(htmlStr);
            }
            //服务类别
            if (window._util.ItemCode.ServiceType != null) {
                var htmlStr = "";
                $.each(window._util.ItemCode.ServiceType, function (ix, item) {
                    htmlStr += '<option value="' + item.Value + '">' + item.Text + '</option>';
                });

                $("#editForm .Skill").html(htmlStr);
                htmlStr = '<option value="" selected="selected">所有</option>' + htmlStr;
                $("#toolbar .query-Skill").html(htmlStr);
            }
            //结算标准
            if (window._util.ItemCode.Payment != null) {
                var htmlStr = "";
                $.each(window._util.ItemCode.Payment, function (ix, item) {
                    htmlStr += '<option value="' + item.Value + '">' + item.Text + '</option>';
                });

                $("#editForm .PaymentId").html(htmlStr);
                //htmlStr = '<option value="" selected="selected">所有</option>' + htmlStr;
                //$("#toolbar .query-PaymentId").html(htmlStr);
            }
            //所属单位、服务单位
            if (window.UserUnit.Role == 0) {
                if (window._util.ItemCode.AllUnit != null) {
                    var htmlStr = "";
                    $.each(window._util.ItemCode.AllUnit, function (ix, item) {
                        htmlStr += '<option value="' + item.Value + '">' + item.Text + '</option>';
                    });

                    htmlStr = '<option value="" selected="selected">平台</option>' + htmlStr;
                    $("#editForm .OwnerUnitId").html(htmlStr);
                    $("#editForm .ServiceUnitId").html(htmlStr);
                }
            } else {
                if (window._util.ItemCode.UserUint != null) {
                    var htmlStr = '<option value="' + window._util.ItemCode.UserUint.Id + '">' + window._util.ItemCode.UserUint.Name + '</option>';
                    $("#editForm .OwnerUnitId").html(htmlStr);
                    $("#editForm .ServiceUnitId").html(htmlStr);
                }
            }
        }
        function initTable() {
            initSelect();
            $('#crewViewTable').bootstrapTable({
                url: window._util.BASE_URL + '/Business/QueryCrew',
                method: 'get',
                dataType: "json",
                cache: true,
                totalField: 'MaxRows',
                dataField: 'Items',
                queryParamsType: "Page",
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                singleSelect: true,
                pagination: true, //分页
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [20, 50, 100, 200, 500],        //可供选择的每页的行数（*）
                search: false, //显示搜索框
                sidePagination: "server", //服务端处理分页
                clickToSelect: true,                //是否启用点击选中行
                showRefresh: false,                  //是否显示刷新按钮
                queryParams: function (params) {
                    params["Name"] = $("#toolbar .query-Name").val();
                    params["IdNo"] = $("#toolbar .query-IdNo").val();
                    params["WorkStart"] = $("#toolbar .query-WorkStart").val();
                    params["Birthday"] = $("#toolbar .query-Birthday").val();
                    params["Gender"] = $("#toolbar .query-Gender").val();
                    params["Type"] = $("#toolbar .query-Type").val();
                    params["Status"] = $("#toolbar .query-Status").val();
                    params["Skill"] = $("#toolbar .query-Skill").val();
                    return params;
                },
                columns: [
                    {
                        checkbox: true,
                    },
                    {
                        field: 'Id',
                        title: '编号',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Name',
                        title: '姓名',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Gender',
                        title: '性别',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'IdNo',
                        title: '身份证',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Type',
                        title: '性质',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Skill',
                        title: '技能',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Status',
                        title: '状态',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'PaymentName',
                        title: '结算标准',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Tel',
                        title: '电话',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'OwnerUnitName',
                        title: '所属单位',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'ServiceUnitName',
                        title: '服务单位',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        title: '照片',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return '<img width="30px" height="30px" src="' + window._util.BASE_URL + '/Business/GetCrewPhoto?id=' + row.Id + "&t=" + new Date().getTime() + '" />';
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return '<button data-id="' + row.Id + '" class="schedule btn btn-warning"><i class="fa fa-edit fa-lg"></i> 排 班</button><button data-id="' + row.Id + '" class="edit btn btn-success"> <i class="fa fa-edit fa-lg"></i> 编 辑</button>';
                        }
                    }
                ]
            });
        }
        //查询
        $("#toolbar .query").click(function () {
            $('#crewViewTable').bootstrapTable('refresh');
        });
        //添加
        $("#toolbar button.add").click(function (args) {
            //表单重置
            $('#page-inner .cls-list').hide();
            $('#editForm input.cls-form-reset').click();
            $("#editForm input.Id").val(0);
            $("#editForm img").attr("src", "");
            $('#page-inner .cls-edit').show();
        });
        //编辑
        $("#crewViewTable tbody").click(function (event) {
            var element = $(event.target);
            if (element.is("button.schedule")) {
                var id = element.data("id");
                $("#page-inner .cls-list").hide();
                $("#page-inner .cls-list-schedule").show();
                loadSchedule(id);
            } else if (element.is("button.edit")) {
                var id = element.data("id");
                $.ajax({
                    url: window._util.BASE_URL + "/Business/GetCrew",
                    method: "GET",
                    dataType: "json",
                    data: "Id=" + id,
                    success: function (resp) {
                        if (resp != null) {
                            $("#editForm input.Id").val(resp.Id);
                            $("#editForm input.Name").val(resp.Name);
                            $("#editForm input.Birthday").val(resp.Birthday);
                            $("#editForm input.Native").val(resp.Native);
                            $("#editForm input.Addr").val(resp.Addr);
                            $("#editForm input.Tel").val(resp.Tel);
                            $("#editForm input.WorkStart").val(resp.WorkStart);
                            $("#editForm input.WorkEnd").val(resp.WorkEnd);
                            $("#editForm input.Training").val(resp.Training);
                            $("#editForm input.IdNo").val(resp.IdNo);
                            $("#editForm input.IdIssuer").val(resp.IdIssuer);
                            $("#editForm input.TrcNo").val(resp.TrcNo);
                            $("#editForm input.TrcIssuer").val(resp.TrcIssuer);
                            $("#editForm input.TrcStart").val(resp.TrcStart);
                            $("#editForm input.HealthNo").val(resp.HealthNo);
                            $("#editForm input.HealthIssuer").val(resp.HealthIssuer);
                            $("#editForm input.HealthStart").val(resp.HealthStart);
                            $("#editForm input.LicenseNo").val(resp.LicenseNo);
                            $("#editForm input.LicenseType").val(resp.LicenseType);
                            $("#editForm input.LicenseIssuer").val(resp.LicenseIssuer);
                            $("#editForm input.LicenseStart").val(resp.LicenseStart);
                            $("#editForm input.Note").val(resp.Note);
                            $("#editForm select.Gender").val(resp.Gender);
                            $("#editForm select.Skill").val(resp.Skill);
                            $("#editForm select.Type").val(resp.Type);
                            $("#editForm select.Status").val(resp.Status);
                            $("#editForm select.Level").val(resp.Level);
                            $("#editForm select.OwnerUnitId").val(resp.OwnerUnitId);
                            $("#editForm select.ServiceUnitId").val(resp.ServiceUnitId);
                            $("#editForm select.PaymentId").val(resp.PaymentId);
                            $("#editForm select.LicenseType").val(resp.LicenseType);
                            $("#editForm td.preview img")[0].src = window._util.BASE_URL + "/Business/GetCrewPhoto?id=" + resp.Id + "&t=" + new Date().getTime();

                            $('#page-inner .cls-list').hide();
                            $('#page-inner .cls-edit').show();
                        } else {
                            alert("获取数据出错");
                        }
                    }
                }).fail(function (H, G) {
                    alert("浏览器超时未响应，请刷新重试");
                });
            }
        });
        //删除
        $("#toolbar button.delete").click(function () {
            var selections = $('#crewViewTable').bootstrapTable('getSelections');
            if (selections != null && selections.length > 0) {
                var idArray = new Array();
                $.each(selections, function (ix, item) {
                    idArray.push(item.Id);
                });
                var jsonData = {
                    ids: idArray
                };
                $.ajax({
                    url: window._util.BASE_URL + "/Business/DeleteCrews",
                    method: "POST",
                    contentType: "application/json;charset=UTF-8",
                    dataType: "json",
                    data: JSON.stringify(jsonData),
                    success: function (resp) {
                        if (resp != null && resp.Result) {
                            alert("删除成功");
                            $('#crewViewTable').bootstrapTable('refresh');
                        } else {
                            alert("删除失败");
                        }
                    }
                }).fail(function (G, F) {
                    alert("浏览器超时未响应，请刷新重试");
                });
            }
        });
        //保存
        $(".cls-edit button.save").click(function () {
            $('#editForm').submit();
        });
        //取消
        $(".cls-edit button.cancel").click(function () {
            $('#page-inner .cls-edit').hide();
            $('#page-inner .cls-list').show();
        });
        $("#editForm").ajaxForm({
            dataType: "json",
            success: function (resp) {
                if (resp != null && resp.Result) {
                    alert(resp.Message);
                    $('#crewViewTable').bootstrapTable('refresh');
                    $('#page-inner .cls-edit').hide();
                    $('#page-inner .cls-list').show();
                } else {
                    alert("保存失败");
                }
            },
            error: function (J, I, K) {
                alert("浏览器超时未响应，请刷新重试");
            }
        });
        //表单编辑校验
        var validate = $("#editForm").validate({
            debug: true,
            focusInvalid: false,
            onkeyup: false,
            rules: {
                Name: {
                    required: true
                },
                Gender: {
                    required: true
                },
                Type: {
                    required: true
                },
                Status: {
                    required: true
                },
                Skill: {
                    required: true
                },
                Level: {
                    required: true
                },
                IdNo: {
                    required: true,
                    identityCodeValid: true
                },
                OwnerUnitId: {
                    required: true
                },
                ServiceUnitId: {
                    required: true
                }
            },
            messages: {
                Name: {
                    required: "姓名不能为空"
                },
                Gender: {
                    required: "性别不能为空"
                },
                Type: {
                    required: "性质不能为空"
                },
                Status: {
                    required: "状态不能为空"
                },
                Skill: {
                    required: "技能不能为空"
                },
                Level: {
                    required: "等级不能为空"
                },
                IdNo: {
                    required: "身份证不能为空"
                },
                OwnerUnitId: {
                    required: "所属单位不能为空"
                },
                ServiceUnitId: {
                    required: "服务单位不能为空"
                }
            }

        });

        function loadImage(J) {
            var I = new FileReader();
            I.onload = function (K) {
                $("#editForm td.preview img")[0].src = K.target.result
            };
            I.readAsDataURL(J);
        }
        $("#editForm input.file").change(function () {
            if (this.files) {
                loadImage(this.files[0]);
            } else {
                alert("您的浏览器不支持HTML5, 无法预览图片");
            }
        });

        /******************************Schedule表格**********************************************************/
        function loadSchedule(crewId) {
            $('#scheduleTable').bootstrapTable({
                url: window._util.BASE_URL + '/Business/QuerySchedule?CrewId=' + crewId,
                method: 'get',
                dataType: "json",
                cache: true,
                totalField: 'MaxRows',
                dataField: 'Items',
                queryParamsType: "Page",
                toolbar: '#toolbar-schedule',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                singleSelect: true,
                pagination: true, //分页
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [20, 50, 100, 200, 500],        //可供选择的每页的行数（*）
                search: false, //显示搜索框
                sidePagination: "server", //服务端处理分页
                clickToSelect: true,                //是否启用点击选中行
                showRefresh: false,                  //是否显示刷新按钮
                queryParams: function (params) {
                    params["CustomerName"] = $("#toolbar-schedule .query-CustomerName").val();
                    params["Start"] = $("#toolbar-schedule .query-Start").val();
                    params["End"] = $("#toolbar-schedule .query-End").val();
                    return params;
                },
                columns: [
                    {
                        checkbox: true,
                    },
                    {
                        field: 'CustomerName',
                        title: '客户姓名',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'ServiceName',
                        title: '服务项目',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Start',
                        title: '服务时间',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'ShiftName',
                        title: '班次',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Ratio',
                        title: '分成比例',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Adjust',
                        title: '调整金额',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Pay',
                        title: '结算金额',
                        align: 'center',
                        hlign: 'center'
                    },
                    {
                        field: 'Note',
                        title: '客户评价',
                        align: 'center',
                        hlign: 'center'
                    }
                ]
            });
        }
        //查询
        $("#toolbar-schedule .query").click(function () {
            $('#scheduleTable').bootstrapTable('refresh');
        });
        //删除
        $("#toolbar-schedule button.delete").click(function () {
            var selections = $('#scheduleTable').bootstrapTable('getSelections');
            if (selections != null && selections.length > 0) {
                var idArray = new Array();
                $.each(selections, function (ix, item) {
                    idArray.push(item.Id);
                });
                var jsonData = {
                    ids: idArray
                };
                if (confirm("您确定要删除所有选中的记录吗？")) {
                    $.ajax({
                        url: window._util.BASE_URL + "/Business/DeleteSchedules",
                        method: "POST",
                        contentType: "application/json;charset=UTF-8",
                        dataType: "json",
                        data: JSON.stringify(jsonData),
                        success: function (resp) {
                            if (resp != null && resp.Result) {
                                alert("删除成功");
                                $('#scheduleTable').bootstrapTable('refresh');
                            } else {
                                alert("删除失败");
                            }
                        }
                    }).fail(function (G, F) {
                        alert("浏览器超时未响应，请刷新重试");
                    });
                }
            }
        });
        //取消
        $("#toolbar-schedule button.cancel").click(function () {
            $("#page-inner .cls-list-schedule").hide();
            $("#page-inner .cls-list").show();
        });

    });
</script>
